<template>
	<view class="content">
		<view class="wrap">
			<u-swiper :list="list" :title="true" indicator-pos="topRight" ></u-swiper>
		</view>
		<view class="notice">
			<u-notice-bar mode="horizontal" :list="notiList"></u-notice-bar>
		</view>
		<view class="box2">
			<view class="" @click="linkTo('../answer/answer')">
				<image src="../../static/imgs/home/1.png" mode=""></image>
				<p>随机练习</p>
			</view>
			<view class="">
				<image src="../../static/imgs/home/2.png" mode=""></image>
				<p>历史真题</p>
			</view>

		</view>
		<c-Loading></c-Loading>
	</view> 
</template>

<script>
	
	export default {
	
		data() {
			return {
				notiList: [],
				list: [],
				
			}
		},
		onLoad() {
			
			let t=this;
			t.$store.commit('setLoadIng',true)
			Promise.all([t.getNotice(),t.getSwiper()]).then(res=>{
					t.notiList=res[0];
					t.list=res[1];
					t.$store.commit('setLoadIng',false)
			})
			
		},
		methods: {
			getNotice(){
				let t = this;
				return new Promise(resolve => {
					
					t.$db.collection('notice').get().then(res => {
					
						resolve(res.result.data[0].notice)
					})
				})
				
			},
			getSwiper(){
				let t = this;
				return new Promise(resolve => {
					t.$db.collection('swiper').get().then(res => {
						resolve(res.result.data)
						
					})
				})
				
			},
			linkTo(url) {
				uni.navigateTo({
					url
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.wrap {
		padding: 20rpx 40rpx 20rpx;
	}

	.box2 {
		display: flex;
		flex-wrap: wrap;
		padding: 20px;

		>view {
			width: 25%;

			image {
				width: 100rpx;
				height: 100rpx;
			}

			p {
				font-size: 24rpx;
			}
		}
	}
</style>
